﻿using UnityEngine;
using UnityEngine.UI;

public class UIPenetrate : MonoBehaviour, ICanvasRaycastFilter
{
    [SerializeField]
    private Image mTargetImage;

    public void SetTargetImage(Image target)
    {
        mTargetImage = target;
    }

    public bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
    {
        if (mTargetImage == null)
        {
            return true;
        }

        return !RectTransformUtility.RectangleContainsScreenPoint(mTargetImage.rectTransform, sp, eventCamera);
    }
}
